home *** CD-ROM | disk | FTP | other *** search
-
- > Hey again,
- > I have a little question..
- > why does this cause me to get an "Out of stack space" Error and what can I
- > do to remedy it?
- > Thanx in advatz!!! :)
-
- This is a classic programing pit fall, every time you jump to
- one procedure from within another, all the data (variables) from the
- procedure you are leaving are tossed on the 'stack' basically they are
- stored in quick temporary memory so they can be recalled quickly when you
- return to the original procedure.
-
- ex.
- Procedure FUN_TIMES
- x=100
- y=320
- ght=345
-
- Proc GOOD_TIMES
-
- End Proc
-
- Now when the program hops to GOOD_TIMES in that last line all the
- variables (x,y,ght) are thrown on the stack, and then recalled again
- whenever GOOD_TIMES returns. Follow all that?
- Wel the problem arises when you have too many nested or looped
- procedure calls, then too much data gets stuck on the stack and it fills
- up, giving you an out of stack erorr, so:
-
- Procedure GOOD_TIMES
-
- y=1002
- x=1232
-
-
- For I=1 to 50
- proc GOOD_TIMES
- Next I
-
- End Proc
-
- Will quickly use up the stack since each time GOOD_TIMES is called anew x
- and y are dumped on the stack not to be cleared until the new GOOD_TIMES
- returns. (which I actually think is never in this case) So too many x's
- and y's build up on the stack (yup even though they all have the same
- value, since Amos doesn't know that) and you get an out of stack error.
- Hpe that clears things up a bit, I deleted your bit of code before I could
- see where your stack error was but bottom line too many looped procedure
- calls or Gosubs (Gosub exhibits the exact same problem, this time because
- the old location (where to return to) is stored on the stack )
- Well hope that wasn't too dense. Let me know if you've anymore
- questions, and happy coding!
-
-
-